<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>库存总览</title>
    <script src="../jQuery/jquery-1.11.2.js"></script>
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/font.css">
    <style>::-webkit-scrollbar{display: none;}</style>
</head>
<body>
<blockquote class="layui-elem-quote news_search">
    <script type="text/html" id="secStock_search">
        <!--多条件查询层-->
        <div style="float: left;display: none">
            <form class="layui-form layui-col-md12 x-so">
                <div class="layui-input-inline">
                    <input type="date" name="date" id="date" placeholder="请输入统计日期" autocomplete="off" class="layui-input"/>
                </div>
                <button id="search" class="layui-btn layui-btn-primary layui-bg-gray" lay-submit lay-filter="search" >
                    <i class="layui-icon">&#xe615;</i>
                </button>
            </form>
        </div>
        <!--多条件查询结束-->

        <!--头部工具栏-->
        <div class="layui-btn-container layui-input-inline" style="margin-left: 1000px;">
            <button class="layui-btn layui-btn-normal" lay-event="total" style="width: 100px;">统计</button>
        </div>
    </script>
    <table class="layui-hide" id="test" lay-filter="test"></table>
    <script>
        layui.use(['table','form','layer'], function () {
            var table = layui.table;
            var form = layui.form;
            var layer=layui.layer;
            var tables=table.render({
                elem: '#test'
                , url: '../RepertoryTotalController/method'
                ,height:"740px"
                ,type:"get"
                ,limit:15
                , toolbar: '#secStock_search' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                    title: '提示'
                    , layEvent: 'LAYTABLE_TIPS'
                    , icon: 'layui-icon-tips'
                }]
                , title: '用户数据表'
                , cols: [[ //表头
                    {field: 'repertoryName', title: '库存名称', sort: true, fixed: 'left'}
                    , {field: 'fundName', title: '基金编号'}
                    , {field: 'operator', title: '操作员', sort: true}
                    , {field: 'repertorydate', title: '统计日期'}
                    , {field: 'repertoryData', title: '已统计数据条数'}
                ]]
                , page: true,
                limits: [5, 10,20,30,50]
            });


            //表格头部工具栏事件代码，根据lay-event属性值判断执行相应的代码
            table.on('toolbar(test)', function(obj) {
                //检查表格选择操作状态
                var checkStatus = table.checkStatus(obj.config.id);
                //判断事件event值
                switch(obj.event) {
                    //批量删除操作：删除选定的多行数据
                    case "total":
                        $.ajax({
                            url:"../RepertoryTotalController/method",
                            type:"put",
                            success:function (data) {
                                if (data=="success"){
                                    layer.msg("更新成功",{icon:1});
                                }else if (data=="fail"){
                                    layer.msg("更新失败",{icon:2});
                                }else layer.msg("data");
                            }
                        });
                        tables.reload("test");
                       break;
                }
                tables.reload("test");
            });


            //判断点击的是搜索
            form.on("submit(search)",function(data){
                //获取数据
                var dataTable=data.field;
                if (dataTable.date!=""){
                    //通过ajax发送查询数据
                    //重载表格，刷新时发送数据
                    table.reload("test",{
                        page:{//刷新后从第几页开始显示
                            curr: 1
                        },
                        where:{
                            date:dataTable.date,
                        }
                    });
                }else{
                    layer.msg("请输入内容");
                }
                return false;
            });

        });
    </script>
</blockquote>
</body>
</html>